Skip to content

ref-code-adaptation: Initial merge request - #15

Open
PresiProdanov wants to merge 26 commits into
devfrom
PPr/initial
Open

ref-code-adaptation: Initial merge request#15
PresiProdanov wants to merge 26 commits into
devfrom
PPr/initial

Conversation

@PresiProdanov

Copy link
Copy Markdown
Collaborator

No description provided.

Max Philip Stachon and others added 20 commits April 22, 2026 22:37
…aptationConflictDetector now uses strategies
…ncarnation mapping, only one class for single- and multi-incarnations
… remove thread-local storage; add unit tests for lifecycle behavior
…onstructor overloads and remove unused methods
…s rebuilt too often; fixes bugs that remained hidden; made the test oracle for the completer cases stricter
@PresiProdanov
PresiProdanov requested a review from MaxStachon July 13, 2026 13:26
@PresiProdanov PresiProdanov self-assigned this Jul 13, 2026

@MaxStachon MaxStachon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial Review für den verbesserten Reference Code Adapter

@PresiProdanov Bitte Kommentare anschauen und bearbeiten/antworten.

Comment thread ref-code-adaptation/REQUIREMENTS.md Outdated

Last updated: 13.07.2026

## Requirements

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nach GitLab verschieben bevor gemerged wird.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die Requirements sind übertragen.

public final class GroupingMappingService {

/** Computes replacements for one mapping only, preventing one mapping from leaking into another. */
public Map<String, String> compute(IncarnationContext context) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was wird in der Map gespeichert? JavaDoc?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaDoc vorhanden - die Map bildetr den einfachen Namen eines konkreten Typs auf den einfachen Namen seines Gruppierungstyps ab.

@MaxStachon MaxStachon Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vielleicht konsistenter, wenn du hier von Inkarnationen oder Inkarnations-Gruppe sprichst?

Schau auch mal an anderen Stellen nach.

@MaxStachon MaxStachon Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oder gleich Map<String, Set<String>>?

Comment on lines +102 to 133
String lowerName = name.toLowerCase(Locale.ROOT);
Map<Integer, List<ISymbol>> refsByPosition = new TreeMap<>();
List<ISymbol> longestFirst = new ArrayList<>(infixList);
longestFirst.sort(
Comparator.comparingInt((ISymbol symbol) -> symbol.getName().length()).reversed());
boolean[] occupied = new boolean[name.length()];
for (ISymbol reference : longestFirst) {
String infix = reference.getName().toLowerCase(Locale.ROOT);
if (infix.isEmpty()) {
continue;
}
int from = 0;
while (from <= lowerName.length() - infix.length()) {
int index = lowerName.indexOf(infix, from);
if (index < 0) {
break;
}
boolean overlaps = false;
for (int i = index; i < index + infix.length(); i++) {
overlaps |= occupied[i];
}
if (!overlaps) {
refsByPosition.computeIfAbsent(index, ignored -> new ArrayList<>()).add(reference);
Arrays.fill(occupied, index, index + infix.length(), true);
}
from = index + infix.length();
}
}
List<ISymbol> result = new ArrayList<>();
refsByPosition.values().forEach(result::addAll);
return result;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gibt es dafür nicht Library-Methoden, z.B. in String oder Strings?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich habe nach einer passenden Library-Methode gesucht. String#indexOf hilft zwar beim Finden einzelner Vorkommen, aber längere Referenznamen müssen Vorrang haben, Treffer dürfen sich nicht überschneidenn und das Ergebnis muss nach der Position im Bezeichner sortiert sein.

@@ -135,38 +160,40 @@ public static Optional<ASTAnnotation> getInfoAnnotation(List<ASTMCModifier> mods
* @return the generated String.
*/
public static String fillTemplate(String template, List<ISymbol> refSymbol) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was ist denn das Template in diesem Kontext?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doku ist jetzt da.

for (ISymbol symbol1 : temps) {
if (!symbol.equals(symbol1) && (matchInfix(symbol.getName(), symbol1.getName()))) {
references.remove(symbol1);
List<ISymbol> result = new ArrayList<>(new LinkedHashSet<>(references));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vielleicht hier noch ein Kommentar.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doku ist da. Duplikate werden entfernt, anschließend werden kürzere Referenznamen verworfen, wenn sie vollständig in einer längeren Referenz enthalten sind.

enforceInterfaceMethodBodies();
}

private boolean invokesMethodOn(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte kommentieren, was diese Methode machen soll.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kommentiert.

}

@SuppressWarnings({"rawtypes", "unchecked"})
private CtExpression<?> missingArgument(CtInvocation<?> invocation, String parameterType) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte kommentieren.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

import spoon.refactoring.Refactoring;

/** Generates, clones and removes Spoon declarations. */
final class SpoonGenerationService {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ggf. Mit SpoonTransformationService kombinieren zu SpoonCRUDUtil (o.ä.).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im Meeting habe ich dir selber vorgeschalgen, beide zu mergen, da keine Doku vorhanden war. Das habe ich jedoch nicht gemacht. SpoonGenerationService : Elemente werden erzeugt, geklont, entfernt oder mit Bodies versehen. SpoonTransformationService verändert dagegen bestehende Deklarationen und Referenzen und besitzt dafür lazy aufgebaute Referenzindizes. Beide Bereiche haben unterschiedliche Zustände und Ausführungsreihenfolgen.

import spoon.reflect.visitor.filter.TypeFilter;

/** Applies all mutations to declarations and references in an already loaded Spoon model. */
final class SpoonTransformationService {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ggf. Mit SpoonGenerationService kombinieren zu SpoonCRUDUtil (o.ä.).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wie erwähnt, das ist eine schlechte Idee. Code ist jetzt besser dokumentiert.

}
}

void rewriteTypeReferenceName(CtTypeReference<?> reference, String newName) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muss das nichtr logisch woanders hin?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja, die Methode wurde verschoben.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants